package com.jd.tran;

import org.apache.rocketmq.client.producer.LocalTransactionState;
import org.apache.rocketmq.client.producer.TransactionListener;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageExt;


public class MyTranListener implements TransactionListener {


    // 执行本地事务代码的方法
    @Override
    public LocalTransactionState executeLocalTransaction(Message message, Object obj) {
        System.out.println("执行了本地事务成功" + obj);
        return LocalTransactionState.COMMIT_MESSAGE;
    }


    //  检查本地事务是否成功的方法
    @Override
    public LocalTransactionState checkLocalTransaction(MessageExt messageExt) {
        System.out.println("检查本地事务，本地事务执行失败！");
        return LocalTransactionState.ROLLBACK_MESSAGE;
    }
}
